﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Service.Contract;
using Sunboxsoft.ChanceData.ServiceProxy.MainServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Views.EventProxies
{
    public class RespResetSceneEventHandler : BaseResponseHandler<RespResetSceneData>
    {
        protected override void OnHandle(RemoteEventProxy remoteEventProxy, Response response, RespResetSceneData responseData)
        {
            if (responseData.IsSuccess)
            {
                // 还原到初始状态
                UI.ScenePart scenePart = remoteEventProxy.RenderView.GetCurrentPart() as ScenePart;
                scenePart.Dispatcher.Invoke(() =>
                {
                    // 重置场景里的视图状态
                    remoteEventProxy.RenderView.ResetScene(scenePart);
                    Common.EventBus.Instance.Publish(new SceneUpdateEvent(remoteEventProxy.RenderView.GetCurrentPart() as ScenePart, SceneUpdateReason.ResetScene));
                });
            }
        }
    }
}
